# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: PumpkinCheshire <me at pumpkincheshire dot com>
# Contributor: Cobalt Space <cobaltspace at protonmail dot com>
# Contributor: Mitch Bigelow <ipha00 at gmail dot com>

pkgname=ncnn
pkgver=20230223
pkgrel=1
pkgdesc='High-performance neural network inference framework optimized for the mobile platform'
url='https://github.com/Tencent/ncnn'
arch=('loong64' 'x86_64')
license=('BSD')
depends=('vulkan-icd-loader')
makedepends=('cmake' 'glslang' 'ninja' 'protobuf' 'vulkan-headers')
optdepends=('protobuf: for onnx2ncnn')
conflicts=('ncnn-git')
source=("$pkgname-$pkgver.tar.gz::https://github.com/Tencent/ncnn/archive/$pkgver.tar.gz")
b2sums=('50b228b920f3c09640b1cdef8247b66a09bbacf64ac66b8fd601973c648221b1f9ff07b0069bdf1f7944db53cbca39c2fa4f3627e2b2ecc3e46e9dc4b38135ab')

build() {
    cmake -B build -S "$pkgname-$pkgver" \
        -GNinja \
        -DCMAKE_BUILD_TYPE='None' \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DNCNN_SHARED_LIB=ON \
        -DNCNN_ENABLE_LTO=ON \
        -DNCNN_VULKAN=ON \
        -DNCNN_SYSTEM_GLSLANG=ON \
        -DNCNN_BUILD_EXAMPLES=OFF \
        -DGLSLANG_TARGET_DIR=/usr/lib/cmake \
        -Wno-dev
    ninja -C build
}

package() {
    DESTDIR="$pkgdir" ninja -C build install
    install -Dm644 "$srcdir"/ncnn-$pkgver/LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname/
}
